{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $operation == 'post' && empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('print', array('op' => 'post'))}">
    添加打印机
    </a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('print', array('op' => 'display'))}">管理打印机</a></li>
    {if $operation == 'post' && !empty($id)}<li class="active"><a href="#">设置打印机</a></li>{/if}
    {if $operation == 'status' && !empty($id)}<li class="active"><a href="#">打印状态</a></li>{/if}
</ul>
{if $operation == 'post'}
<div class="main">

    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1">
        <div class="panel panel-default">

            <div class="panel-heading">
                打印机设置
            </div>

            <div class="panel-body">

                <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">所属店铺</label>
                    <div class="col-sm-4">
                   <select name="cateid" class='form-control'>
							<option value="0">请选择店铺</option>
						{loop $category $row}
						<option value="{$row['id']}" {if $row['id'] == $print['cateid']} selected="selected"{/if}>{$row['name']}</option>
						{/loop}
					</select>
                    </div></div>
                     <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">机器号</label>
                    <div class="col-sm-9">
                        <input type="text" name="deviceno" class="form-control" value="{$print['deviceno']}" />
                    </div></div>
                     <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">打印机key</label>
                    <div class="col-sm-9">
                        <input type="text" name="key" class="form-control" value="{$print['key']}" />
						<span class="help-block">在365官网绑定打印机后生成的key。</span>
                        <!--这里改了<span class="help-block">在飞鹅官网绑定打印机后生成的key。</span> -->
                    </div></div>
                     <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">打印联数</label>
                    <div class="col-sm-9">
                        <input type="text" name="printtime" class="form-control" value="{$print['printtime']}" />
                    </div></div>
                     <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">二维码链接</label>
                    <div class="col-sm-9">
                        <input type="text" name="qr" class="form-control" value="{$print['qr']}" />
                        <span class="help-block">留空则不打印二维码。</span>
                    </div></div>
                     <div class="form-group">
                     <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否启用</label>
                    <div class="col-sm-9">
                    <label class='radio-inline'>
                             <input type='radio' name='enabled' value='1' {if $print['enabled'] == 1 || empty($print['id'])}checked{/if} /> 是
                         </label>
                         <label class='radio-inline'>
                             <input type='radio' name='enabled' value='0' {if $print['enabled'] == 0 && !empty($print['id'])}checked{/if} /> 否
                         </label>
                    </div></div>

                
		<div class="form-group col-sm-12">

			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />

			<input type="hidden" name="token" value="{$_W['token']}" />

		</div>

    </form>

</div>
<script type="text/javascript" src="../web/resource/components/colorpicker/spectrum.js"></script>
<link type="text/css" rel="stylesheet" href="../web/resource/components/colorpicker/spectrum.css" />
<script type="text/javascript">
<!--
	$(function(){
		colorpicker();
	});
//-->
</script>
{elseif $operation == "status"}
<div class="main">
	<div class="category">
		<form action="" method="post">
		<table class="table table-hover">
			<thead>
				<tr>
					<th>{$print['name']['name']}——打印机状态</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
			
				<tr>
					<td>状态码：</td>
					<td>
						{$print['status']}
					</td>
				</tr>
				
                <tr>
				<td>
					<input name="submit" type="submit" value="打印查询" class="btn btn-primary span3">
					<input type="hidden" name="token" value="{$_W['token']}" />
				</td>
                <td></td>
			</tr>
            <tr><td>
             状态码的返回有如下几种：
					</td>
					<td>1、{"status=1&result=online":"在线,工作状态正常"}。<br />2、{"status":"离线"}，表示打印机没有开机，或手机卡不能联网。<br />4、{"status":"在线,工作状态不正常"}，表示打印机已开机，但没纸或不能正常打印。</td>
					
				</tr>
	
			</tbody>
		</table>
		</form>
	</div>
</div>
<link rel="stylesheet" type="text/css" href="../addons/jufeng_wcy/images/jquery.datetimepicker.css" />
<script type="text/javascript" src="../addons/jufeng_wcy/images/jquery.datetimepicker.js"></script>

<script type="text/javascript">

		$("#datepicker_starttime").datetimepicker({
yearOffset:0,
	lang:'ch',
	timepicker:false,
	format:'Y-m-d',
	formatDate:'Y-m-d',
		});

	</script>	
{elseif $operation == "display"}
<div class="main">

    <div class="category">

        <form action="" method="post" onsubmit="return formcheck(this)">

			<div class="panel panel-default">

				<div class="panel-body table-responsive">

					<table class="table table-hover">

						<thead>

							<tr>

								<th style="width:10px;"></th>

								<th style="width:80px;">机器号</th>
								<th style="width:150px;">所属店铺</th>
                                <th style="width:150px;">打印联数</th>
								<th style="width:150px;">是否启用</th>
                                <th style="width:150px;">操作</th>

							</tr>

						</thead>

						<tbody>
			{loop $print $row}
				<tr>
					<td></td>
					<td>{$row['deviceno']}</td>
					<td><div class="type-parent">{$row[0]['name']}</b></div></td>
                    <td><div class="type-parent">{$row['printtime']}</b></div></td>
                    <td>{if $row['enabled'] == 1}<span class="label label-success">是</span>{else}<span class="label label-danger">否</span>{/if}</td>
					<td>
                    <a href="{php echo $this->createWebUrl('print', array('op' => 'status', 'id' => $row['id']))}">打印状态</a>&nbsp;&nbsp;
                    <a href="{php echo $this->createWebUrl('print', array('op' => 'post', 'id' => $row['id']))}">编辑</a>&nbsp;&nbsp;
                    <a href="{php echo $this->createWebUrl('print', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此打印机吗？');return false;">删除</a></td>
				</tr>
				
			{/loop}
				<tr>
					<td></td>
					<td colspan="5">
						<a href="{php echo $this->createWebUrl('print', array('op' => 'post'))}"><i class="fa fa-plus-circle"></i> 添加新打印机</a>
					</td>
				</tr>
			</tbody>

					</table>

				</div>

           </div>

        </form>

    </div>

</div>

{/if}

{template 'footer'}

